package com.atguigu.product.conterller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.atguigu.order.Order;
import com.atguigu.product.properties.OrderProperties;
import com.atguigu.product.service.OrderService;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api/order")
@RestController
public class OrderConterller {
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderProperties orderProperties;

    @GetMapping("/createOrer/{userId}/{productId}")
    public Order createOrder(@PathVariable("userId") Long userId,
                             @PathVariable("productId") Long productId) {
        Order order = orderService.createOrder(userId, productId);
        return order;
    }
    @GetMapping("/seckill/{userId}/{productId}")
    public Order seckill(@PathVariable("userId") Long userId,
                             @PathVariable("productId") Long productId) {
        Order order = orderService.createOrder(userId, productId);
        return order;
    }

//    @Value("${order.timeout}")
//    String timeout;
//    @Value("${order.auto-confirm}")
//    String autoConfirm;
//    @GetMapping("/config1")
//    public String config1(){
//        return "order timeout: " + autoConfirm
//                + " auto-confirm: " + timeout;
//
//    }

//    @GetMapping("/config")
//    public String config(){
//        return "order timeout: " + orderProperties.getTimeout()
//                + " auto-confirm: " + orderProperties.getAutoConfirm()
//                + " db-url: " + orderProperties.getDbUrl();
//
//    }

}
